package com.jd.jerry.study.service;

import com.jd.jerry.study.dao.CityMapper;
import com.jd.jerry.study.dao.HotelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * Created by chede on 2017/7/17.
 */
@Service
public class SearchServiceImpl{

    @Autowired
    private CityMapper cityMapper;

    @Autowired
    private HotelMapper hotelMapper;


    public void methodA() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        System.out.println(cityMapper.findByState("CA"));
        Method methodB = this.getClass().getDeclaredMethod("methodB", String.class);
        methodB.invoke(this,"123");
    }

    @Transactional
    public void methodB(String a) {
        cityMapper.update(1L,"chedejun");
        hotelMapper.update(1L,"chedejun");
        throw new IllegalStateException();
    }


}
